﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Bootstrapper.cs" company="WordSteps.com">
//   All rights reserved
// </copyright>
// <summary>
//   Defines the Bootstrapper type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace RapidDict
{
    using System.Windows;
    using Microsoft.Practices.Composite.Modularity;
    using Microsoft.Practices.Composite.UnityExtensions;
    using Infrastructure.Interfaces;
    using Modules.ContextTrayMenuService;
    using Modules.HotKeyService;
    using Modules.LanguagePairService;
    using Modules.LanguagesToolbar;
    using Modules.Menu;
    using Modules.PronunciationService;
    using Modules.TranslationService;
    using Modules.Translator;

    class Bootstrapper : UnityBootstrapper
    {
        protected override IModuleCatalog GetModuleCatalog()
        {
            var catalog = new ModuleCatalog();
            catalog
                .AddModule(typeof(MenuModule), "LanguagePairServiceModule", "LanguagePairServiceModule", "TranslationServiceModule")
                .AddModule(typeof(PronunciationServiceModule))
                .AddModule(typeof(LanguagePairServiceModule))
                .AddModule(typeof(ContextTrayMenuServiceModule))
                .AddModule(typeof(TranslationServiceModule))
                .AddModule(typeof(HotKeyServiceModule))
                .AddModule(typeof(LanguagesToolbarModule), "LanguagePairServiceModule")
                .AddModule(typeof(TranslatorModule), "TranslationServiceModule");
                
            return catalog;
        }
        
        protected override DependencyObject CreateShell()
        {
            this.Container.RegisterInstance<IAppViewService>(new Shell());
            var presenter = Container.Resolve<ShellPresenter>();
            IAppViewService view = presenter.View;

            view.ShowApp();
            
            return view as DependencyObject;
        }
    }
}
